package game.efekti;

import util.INIGroup;
import util.Util;
import game.Character;
import game.DamageType;
import game.EffectStage;
import game.MagicEffect;
import game.Item.ItemType;

public class Leech extends MagicEffect {

	int damage;
	
	@Override
	public EffectStage getStage() {
		return EffectStage.TargetOnStrike;
	}

	@Override
	public boolean canHazTip(ItemType tip) {
		return tip.equals(ItemType.WEAPON) || tip.equals(ItemType.ARMOR) || tip.equals(ItemType.SHIELD);
	}

	@Override
	public void doEffect(Character caster, Character target) {
		target.SufferDamage(this.damage, DamageType.Physical,caster);
	}

	@Override
	public String toString() {
		String ret;
		ret = "Leeches " + this.damage + " HP";
		return ret;
	}

	@Override
	public void generateForLevel(int lvl) {
		this.damage = Util.getRndInt(1, lvl/4+5);
	}

	@Override
	public boolean loadFromFile(INIGroup grupa) {
		tag = grupa.getString("Tag");
		damage = grupa.getInteger("Damage", 0);
		return true;
	}

	@Override
	public void init() {}
	
	@Override
	public boolean stacksWith(MagicEffect e) {
		return e instanceof Leech;
	}

	@Override
	public void absorb(MagicEffect e) {
		if(stacksWith(e))
			damage += ((Leech)e).damage;
	}

}
